function fnUnloadHandler() 
{ 
    if (isBrowserClosed())
    {
      document.aspnetForm.action="public/Logoff.aspx";
      document.aspnetForm.method="post";
      document.aspnetForm.submit();
      document.Prova.submit();
    }  
}   

function isBrowserClosed()
{
    var browserWindowWidth = 0;
    var browserWindowHeight = 0;

    if (parseInt(navigator.appVersion) > 3)
    {
        if (navigator.appName == "Netscape")
        {
            browserWindowWidth = window.innerWidth;
            browserWindowHeight = window.innerHeight;
        }
        if (navigator.appName.indexOf("Microsoft") !=- 1)
        {
            browserWindowWidth = top.window.document.body.offsetWidth;
            browserWindowHeight = top.window.document.body.offsetHeight;
        }
    }
    return (event.clientY < 0 && event.screenX > (browserWindowWidth - 25)) ? true : false;
}

function backButtonOverride()
{
    setTimeout("backButtonOverrideBody()", 1);
}

function backButtonOverrideBody()
{
    try 
    {
        history.forward();
    } catch (e) 
    {
        // OK to ignore
    }

    // Every quarter-second, try again. The only guaranteed method for Opera, Firefox,
    // and Safari, which don't always call onLoad but *do* resume any timers when returning to a page
    setTimeout("backButtonOverrideBody()", 500);
}
